﻿using System.Drawing;
using System.Windows.Forms;
using Home.MobileSales.Sales.Interface;

namespace Home.MobileSales.Sales.View
{
    public partial class SplashWindowForm : Form, ISplashWindowView
    {
        static Bitmap backgroundBmp = null;

        public SplashWindowForm()
        {
            InitializeComponent();
            PaintProcess(0, "Ініціалізація");
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Font font = new Font("Arial", 10, FontStyle.Bold);
            if (backgroundBmp == null)
                backgroundBmp = (Bitmap)Properties.Resources.ResourceManager.GetObject("SplashBack");
            e.Graphics.DrawImage(backgroundBmp, 0, 0);
            e.Graphics.DrawString("MobileSales", font, new SolidBrush(Color.Yellow), 65, 40); 
            e.Graphics.DrawString("Завантаження...", font, new SolidBrush(Color.Yellow), 65, 78);            
        }

        public void PaintProcess(int percent, string text)
        {
            this.Invalidate(new Rectangle(60, 100, 200, 50));
            Application.DoEvents();
            progressBar.Value = percent;
            Font font = new Font("Arial", 10, FontStyle.Bold);
            Graphics gr = this.CreateGraphics();
            gr.DrawString(text, font, new SolidBrush(Color.Yellow), 65, 108);
        }
    }
}